import React from 'react';
import { Form, Row, Col } from 'antd';
import LimitInput from '@/components/LimitInput';
import Pre from '@/components/Pre';
import { UploadOssCompact } from '@/containers';
import { renderFormItem } from '@/utils/utils';

const Info = ({ form, formValueMap = {}, checkEditable }) => {
    const { getFieldDecorator, getFieldValue } = form;

    return (
        <Row>
            <Row>
                <Col span={24}>
                    <Form.Item label="调岗类型">转岗</Form.Item>
                </Col>
            </Row>
            <Row>
                <Col span={24}>
                    <Form.Item label="调岗理由">
                        {renderFormItem(
                            getFieldDecorator('reason', {
                                rules: [
                                    { required: true, message: '请输入调岗理由' },
                                    {
                                        min: 1,
                                        max: 4000,
                                        message: '请输入1~4000个字符'
                                    }
                                ]
                            })(<LimitInput area rows={4} placeholder="请输入" maxLength={4000} />),
                            <Pre>{formValueMap.reason}</Pre>,
                            checkEditable('reason')
                        )}
                    </Form.Item>
                </Col>
            </Row>
            <Row>
                <Col span={24}>
                    <Form.Item
                        label="补充说明"
                        extra={
                            checkEditable('additionalRemarkUrl') &&
                            '支持图片、办公文件等多种格式(doc、docx、pdf、jpg、jpeg、xls、xlsx、ppt、pptx、rar、zip、7z)，单个文件大小100M以内，最多上传10个'
                        }
                    >
                        {getFieldDecorator('additionalRemarkUrl')(
                            <UploadOssCompact
                                rules={[
                                    { max: 100 },
                                    { length: 10 },
                                    {
                                        type: [
                                            'doc',
                                            'docx',
                                            'pdf',
                                            'jpg',
                                            'jpeg',
                                            'xls',
                                            'xlsx',
                                            'ppt',
                                            'pptx',
                                            'rar',
                                            'zip',
                                            '7z'
                                        ]
                                    }
                                ]}
                                editable={checkEditable('additionalRemarkUrl')}
                            />
                        )}
                        {!getFieldValue('additionalRemarkUrl') && !checkEditable('additionalRemarkUrl') ? '无' : ''}
                    </Form.Item>
                </Col>
            </Row>
        </Row>
    );
};

export default Info;
